Setting = class()

function Setting:init()
    self.showing = false
    self.xOffset = WIDTH
    
    self.back = STButton(60,HEIGHT - 50,LP.back,"Project:RB","Project:B")
    self.back.width = 100
    self.back.height = 60
    self.back.color = color(255, 255, 255, 255)
    self.back.pressedColor = color(136, 135, 135, 255)
    self.back.clicked = function()
        tween(0.5,self,{xOffset = WIDTH},tween.easing.cubicOut,function() self.showing = false
            saveSetting()
        end)
    end
    
    self.buttons = {}
    local b = STSwitch(WIDTH * 0.3,HEIGHT * 0.8,300,70, LP.settings.ShowDebug,"Project:GB",SettingList.ShowDebug)
    b.changed = function(t)
        SettingList.ShowDebug = t
    end
    table.insert(self.buttons,b)
    
    b = STSwitch(WIDTH * 0.7,HEIGHT * 0.8,300,70, LP.settings.ShowDebugCollision,"Project:GB",SettingList.ShowDebugCollision)
    b.changed = function(t)
        SettingList.ShowDebugCollision = t
    end
    table.insert(self.buttons,b)
    c = STSwitch(WIDTH * 0.3,HEIGHT * 0.7,300,70,LP.settings.ShowTouchPos,"Project:GB",SettingList.ShowTouchPos)
    
    c.changed = function(t)
        SettingList.ShowTouchPos = t
    end
    table.insert(self.buttons,c)
    
end

function Setting:show()
    self.showing = true
    self.xOffset = WIDTH
    tween(0.5,self,{xOffset = 0},tween.easing.cubicOut)
    
end

function Setting:draw()
    pushMatrix()
    pushStyle()
    textMode(CENTER)
    translate(self.xOffset,0)
    noStroke()
    fontSize(40)
    fill(255, 255, 255, 255)
    text(LP.setting,WIDTH/2,HEIGHT-50)
    self.back:draw()
    fontSize(30)
    fill(0, 0, 0, 255)
    
    for k,v in pairs(self.buttons) do
        v:draw()
    end
    popStyle()
    popMatrix()
    
end

function Setting:touched(touch)
    self.back:touched(touch)
    for k,v in pairs(self.buttons) do
        v:touched(touch)
    end
end

